# 短时间实现堆排序有困难，但可以借助heapq模块快速实现
def heapsort_use_heapq(iterable):
    from heapq import heappush, heappop
    items = []
    for value in iterable:
        heappush(items, value)
    return [heappop(items) for i in range(len(items))]


l = [2, 1, 3, 7, 5, 8]
result = heapsort_use_heapq(l)
print(result)

